今天要介紹的是非常好用的佈局容器,LinearLayout是常常被拿來使用的工具,拿來排版非常的好用,LinearLayout提供了簡單的排列方式,可讓你在畫面中將元件水平或垂直地堆疊或排列。
以下為LinearLayout的特點:
LinearLayout常用的屬性:
<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="350dp"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:orientation="horizontal">
            <TextView
                android:id="@+id/textView4"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="1"
                android:textSize="34sp"
                android:background="#00FFFF"/>
            <TextView
                android:id="@+id/textView5"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:text="2"
                android:textSize="34sp"
                android:background="#1AFD9C	"/>
        </LinearLayout>
        <TextView
            android:id="@+id/textView6"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center"
            android:text="3"
            android:textSize="34sp"
            android:background="#FFFF37" />
    </LinearLayout>
呈現的結果如下
只要能運用好設定屬性,就可以用出非常多種不同的排版